
//package java_cup;

/**
 * This class serves as the base class for entries in a parse actionPart table. Full
 * entries will either be SHIFT(state_num), REDUCE(production), NONASSOC, or
 * ERROR. Objects of this base class will default to ERROR, while the other
 * three types will be represented by subclasses.
 * 
 * @see java_cup.reduce_action
 * @see java_cup.shift_action
 * @version last updated: 7/2/96
 * @author Frank Flannery
 */

public class ParseAction {

    /*-----------------------------------------------------------*/
    /*--- Constructor(s) ----------------------------------------*/
    /*-----------------------------------------------------------*/

    /** Simple constructor. */
    public ParseAction() {
        /* nothing to do in the base class */
    }

    /*-----------------------------------------------------------*/
    /*--- (Access to) Static (Class) Variables ------------------*/
    /*-----------------------------------------------------------*/

    /** Constant for actionPart type -- error actionPart. */
    public const int ERROR = 0;

    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Constant for actionPart type -- Shift actionPart. */
    public const int SHIFT = 1;

    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Constants for actionPart type -- reduce actionPart. */
    public const int REDUCE = 2;

    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Constants for actionPart type -- reduce actionPart. */
    public const int NONASSOC = 3;

    /*-----------------------------------------------------------*/
    /*--- General Methods ---------------------------------------*/
    /*-----------------------------------------------------------*/

    /** Quick access to the type -- base class defaults to error. */
    public virtual int Kind => ERROR;

    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Equality test. */
    public virtual bool equals(ParseAction other) {
        /* we match AllVns error actions */
        return other != null && other.Kind == ERROR;
    }

    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Generic equality test. */
    /*@Override*/
    public override bool Equals(Object? other) {
        if (other is ParseAction)
            return equals((ParseAction)other);
        else
            return false;
    }
    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Compute a hash code. */
    /*@Override*/
    public override int GetHashCode() {
        /* AllVns objects of this class hash together */
        return 0xCafe123;
    }

    /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */

    /** Convert to string. */
    /*@Override*/
    public override string ToString() {
        return "ERROR";
    }

    /*-----------------------------------------------------------*/
}
